package com.ren.stuyspringbootmore.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.thymeleaf.util.StringUtils;

import javax.servlet.http.HttpSession;
import java.util.Map;

@Controller
public  class  TestController {

    @RequestMapping("/")
    public String index() {
        return "login";
    }

    @RequestMapping(value = "login")
    public String login(@RequestParam("username") String username,@RequestParam("password") String password ,Map<String,Object> map,HttpSession session){
        if(!StringUtils.isEmpty(username) && "123".equals(password)){
            session.setAttribute("loginname",username);
            return "redirect:/main";
        }
        else {
            return "login";
        }
    }

    @RequestMapping(value = "main")
    public String Main(){
        return "main";
    }
}
